package mce.web.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import mce.web.controller.model.SapMessageModel;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.SessionAttributes;
import org.springframework.web.servlet.ModelAndView;


@Controller
@RequestMapping("/process-result")
@SessionAttributes("sapMessageModel")
public class ResultPageController {
	public static final String CREATE_ACCOUNT = "createAccount";
	public static final String FORGOT_USERNAME = "forgotUsername";
	public static final String FORGOT_PASSWORD= "forgotPassword";
	/**
	 * SAP Message.jsp
	 **/
	@RequestMapping("/create-account")
	public ModelAndView createAccountSubmit( final HttpServletRequest request, final HttpServletResponse response){		
		SapMessageModel sapMessageModel = new SapMessageModel();
		sapMessageModel.setShowLeft(true);
		sapMessageModel.setShowRight(true);
		sapMessageModel.setTitleLeft("Create New Account");
		sapMessageModel.setMessage("E-Mail sent successfully.");
		sapMessageModel.setBackButtonText("BACK");
		sapMessageModel.setBackButtonLink("login");
		return new ModelAndView("SAPMessage","sapMessageModel",sapMessageModel);
	}
	@RequestMapping("/forgot-username")
	public ModelAndView forgotUsername( final HttpServletRequest request, final @RequestParam("actionName") String actionName,
			final HttpServletResponse response){		
		SapMessageModel sapMessageModel = new SapMessageModel();
		sapMessageModel.setShowLeft(true);
		sapMessageModel.setShowRight(true);
		sapMessageModel.setTitleLeft("Forgot Username");
		sapMessageModel.setMessage("E-Mail sent successfully.");
		sapMessageModel.setBackButtonText("BACK");
		sapMessageModel.setBackButtonLink("login");
		if(!actionName.equals("BACK"))
			return new ModelAndView("SAPMessage","sapMessageModel",sapMessageModel);
		else
			return new ModelAndView("Login");
	}
	@RequestMapping("/forgot-password")
	public ModelAndView forgotPassword( final HttpServletRequest request, final @RequestParam("actionName") String actionName,
			final HttpServletResponse response){		
		SapMessageModel sapMessageModel = new SapMessageModel();
		sapMessageModel.setShowLeft(true);
		sapMessageModel.setShowRight(true);
		sapMessageModel.setTitleLeft("Forgot Password");
		sapMessageModel.setMessage("E-Mail sent successfully.");
		sapMessageModel.setBackButtonText("BACK");
		sapMessageModel.setBackButtonLink("login");
		if(!actionName.equals("BACK"))
			return new ModelAndView("SAPMessage","sapMessageModel",sapMessageModel);
		else
			return new ModelAndView("Login");
	}
	@RequestMapping("/change-password")
	public ModelAndView changePassword( final HttpServletRequest request, final @RequestParam("actionName") String actionName,
			final HttpServletResponse response){		
		SapMessageModel sapMessageModel = new SapMessageModel();
		sapMessageModel.setShowLeft(true);
		sapMessageModel.setShowRight(true);
		sapMessageModel.setTitleLeft("Change Password");
		sapMessageModel.setMessage("E-Mail sent successfully.");
		sapMessageModel.setBackButtonText("BACK");
		sapMessageModel.setBackButtonLink("mce-account");
		if(!actionName.equals("BACK"))
			return new ModelAndView("SAPMessage","sapMessageModel",sapMessageModel);
		else
			return new ModelAndView("Account");
	}
}
